const {Tray,Menu} = require ('electron')
const path = require('path')


const number = 19
function createTray(app,win){
    const tray = new Tray (path.join(__dirname, './static/icon.png'))
    tray.setToolTip('通讯录')
    tray.on('click',() => {
        win.isVisible()?win.hide():win.show()
    })
    tray.setContextMenu(Menu.buildFromTemplate([
        {
            label: "显示主窗口", 
            icon: path.join(__dirname,"./build/icons/16x16.png"),      
            click: function() {
                win.show();         
            } //打开相应页面
        },
        { label: '新增联系人',click:()=>{
            console.log('add');
        }},
        { label: '查找联系人',click:()=>{
            console.log('search');
        }},
        { label: '当前人数：'+number},
        { label: '退出',click:()=>{
            app.quit()
        }}
    ]))
}

module.exports = createTray